高手该个java程序 急`~~~~~

来源:百度知道 编辑:UC知道 时间:2024/04/27 17:59:19
package testpackage;
class Horse extends Animal{
String horseName;
int age;
char sex;
Horse(String horseName,int age,char sex){
super("Horse");
className="Horse";
hasFeet=true;
this.horseName=horseName;
this.age=age;
this.sex=sex;
}
Horse(String horseName){
this(horseName,20,'M');
}
void haveHorseDinner(){
System.out.println("I am"+horseName+"!");
eat();
}
}
public class TestClass{
public static void main(String []args){
Animal a=new Animal("Human");
a.eat();
Horse h=new Horse("white");
h.eat();
}
}

package testpackage;
class Horse extends Animal{
String horseName;
int age;
char sex;
Horse(String horseName,int age,char sex){
super("Horse");
className="Horse";
hasFeet=true;
this.horseName=horseName;
this.age=age;
this.sex=sex;
}
Horse(String horseName){
this(horseName,20,'M');
}
void haveHorseDinner(){
System.out.println("I am"+horseName+"!");
eat(); //这是什么?
}
}
public class TestClass{
public static void main(String []args){
Animal a=new Animal("Human");
a.eat();
Horse h=new Horse("white");
h.eat();
}
}
还有你想要表达的是什么?

什么意思

Animal这个类呢??里面是什么内容哦......

package testpackage;
class Horse extends Animal{
String horseName;
int age;
char sex;
Horse(String horseName,int age,char sex){
super("Horse